using System;
using System.Collections.Generic;
using System.Text;
using System.Web.UI;

namespace OpenFlashChartLib
{
    public class BarGraphType : RenderBase, IValueSetRenderer
    {
        public static readonly string BarGraphToken = "filled_bar";
        private int _valueSet = 0;
        private int _alpha;
        private string _color;
        private string _oulineColor;
        private string _legendText;
        private int? _legendTextHeight;

        public BarGraphType(int _alpha, string _color, string _legendText, int? _legendTextHeight)
        {
            this.Alpha = _alpha;
            this.LegendTextHeight = _legendTextHeight;
            this.LegendText = _legendText;
            this.Color = _color;
            // Outline color set to fill color by default
            this._oulineColor = _color;
        }

        /// <summary>
        /// The number of the set of values. It neede to wirte lile bar_2, bar_3 for graph type and values
        /// value_2, value_3
        /// </summary>
        public int ValueSet
        {
            get { return _valueSet; }
            set { _valueSet = value; }
        }

        /// <summary>
        /// Pie part transparency. 100 - no transparency, 0 - full transparency
        /// </summary>
        public int Alpha
        {
            get { return _alpha; }
            set { _alpha = value; }
        }

        /// <summary>
        /// 6 hexadecimal digits of bar color with first # sign
        /// </summary>
        public string Color
        {
            get { return _color; }
            set { _color = value; }
        }
        
        public string LegendText
        {
            get { return _legendText; }
            set { _legendText = value; }
        }

        public int? LegendTextHeight
        {
            get { return _legendTextHeight; }
            set { _legendTextHeight = value; }
        }

        /// <summary>
        /// 6 hexadecimal digits of legend text color with first # sign
        /// </summary>
        public string OulineColor
        {
            get { return _oulineColor; }
            set { _oulineColor = value; }
        }

        /// <summary>
        /// The graph tocken wich will be rendered. Like bar=..., or 3d_bar=... etc
        /// </summary>
        public virtual string GraphTypeTocken
        {
            get { return BarGraphToken; }
        }

        public override void RenderContent(HtmlTextWriter writer)
        {
            string token = GraphTypeTocken;
            if (ValueSet > 0)
                token += "_" + ValueSet;
            writer.Write(token);
            writer.Write("=");
            writer.Write(Alpha);
            writer.Write(",");
            writer.Write(Color);
            writer.Write(",");
            writer.Write(OulineColor);
            writer.Write(",");
            writer.Write(LegendText);
            if (LegendTextHeight != null)
            {
                writer.Write(",");
                writer.Write(LegendTextHeight.Value);
            }
        }
    }
}
